/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.aeso.betabit.util;

import br.aeso.betabit.entity.Evento;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import java.util.List;
import javax.ws.rs.core.MediaType;

/**
 *
 * @author Edson
 */
public class RESTClient {

    protected Client client;
    protected WebResource webResource;

    public RESTClient() {
        ClientConfig clientConfig = new DefaultClientConfig();
        clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
        client = Client.create(clientConfig);
        webResource = client.resource("http://localhost:8083/betabit/eventoservice/");
    }
    
    public List<Evento> getEventos() {
        return (List<Evento>) webResource.path("eventos").accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Evento>>() {});
    }
}